import Vue from 'vue'
import VueRouter from 'vue-router'
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
Vue.use(VueRouter)
/* Layout */
import Layout from '@/views/layout/Layout'
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        // component: () => import('@/views/redirect/index')
        component: r => require.ensure([], () => r(require('@/views/redirect/index')), 'comm')
      }
    ]
  },
  {
    path: '/login',
    // component: () => import('@/views/login/index'),
    component: r => require.ensure([], () => r(require('@/views/login/index')), 'comm'),
    hidden: true
  },
  // {
  //   path: '/auth-redirect',
  // component: () => import('@/views/login/authredirect'),
  //   hidden: true
  // },
  {
    path: '/404',
    // component: () => import('@/views/errorPage/404'),
    component: r => require.ensure([], () => r(require('@/views/errorPage/404')), 'comm'),
    hidden: true
  },
  {
    path: '/401',
    // component: () => import('@/views/errorPage/401'),
    component: r => require.ensure([], () => r(require('@/views/errorPage/401')), 'comm'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        // component: () => import('@/views/dashboard/index'),
        component: r => require.ensure([], () => r(require('@/views/dashboard/index')), 'comm'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'zhishicangku', noCache: true, affix: true }
      }
    ]
  }
]

export default new VueRouter({
  // mode: 'history', //后端支持可开
  // base: 'system1.html',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
